<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::get('/', function(){
	$resp = View::make('home');

    if( Auth::check() ){
        return $resp->with([
            'user'=>Auth::user()
        ]);
    }else{
        return $resp;
    }
});


Route::controller('authority', 'AuthorityController');

Route::group(['before'=>'auth'], function() {

    Route::controller('/ng', 'NgController');

    Route::get('/personal', function () {
        return View::make('personal');
    });

    Route::get('/lesson', function () {
        return View::make('lesson');
    });

    Route::group(['prefix' => 'api', 'before' => 'csrf_header|role'], function () {

        Route::controller('personal', 'PersonalController');

        Route::resource('lesson', 'LessonController');
        Route::resource('lesson/{lessonId}/discussion', 'LessonDiscussionController');
        Route::resource('lesson/{lessonId}/student', 'LessonStudentController');
        Route::resource('lesson/{lessonId}/discussion/{discussionId}/reply', 'LessonDiscussionReplyController');
        Route::resource('lesson/{lessonId}/resource', 'LessonResourceController');

        Route::resource('messages', 'MessageController');    //私信

        Route::resource('unit', 'UnitController');  //单位信息

        Route::controller('/user', 'UserController');   //获取用户的有关信息


        Route::controller('/tmp-file', 'TempFileController');

        Route::resource('callname', 'CallnameController');
        Route::post('callname/excel', 'CallnameController@excel');
        Route::resource('callname/{listId}/student', 'CallnameStudentController');

    });

    Route::group(['prefix' => 'download'], function () {
        Route::get('lesson/{lessonId}/resource/{resourceId}', 'LessonResourceController@show');
    });

});
